import java.util.Map;
import java.util.HashMap;

public class ReplayCar{

	public static int orderCount;
	public static final Map<Integer, BlackBox> orderMap = new HashMap<Integer, BlackBox>();

	public static void addReplay(BlackBox bb) {
		orderCount++;
		orderMap.put(orderCount, bb);
	}

	public static void replayMove(BlackBox bb) {

		MarsCar car = new MarsCar(bb.getStart());
		for (String exe : bb.getOrder()) {
			if ("w".equals(exe)) {
				car.getPoint().forward();
			}
			if ("s".equals(exe)) {
				car.getPoint().back();
			}
			if ("a".equals(exe)) {
				car.getPoint().left();
			}
			if ("d".equals(exe)) {
				car.getPoint().right();
			}

			System.out.println("repaly:" + car);
		}
	}

	public static void replayMove(int orderId) {
		BlackBox bb = orderMap.get(orderId);

		Points p = new Points(bb.getStart().getXpoint(), bb.getStart().getYpoint());
		MarsCar car = new MarsCar(p);
		for (String exe : bb.getOrder()) {
			if ("w".equals(exe)) {
				car.getPoint().forward();
			}
			if ("s".equals(exe)) {
				car.getPoint().back();
			}
			if ("a".equals(exe)) {
				car.getPoint().left();
			}
			if ("d".equals(exe)) {
				car.getPoint().right();
			}

			System.out.println("repaly:" + car);
		}
	}
}